package com.sq.partner.manager.service.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.FacadeAppFormDao;
import com.sq.partner.manager.dao.FacadeAppInsuredDao;
import com.sq.partner.manager.mybatis.model.FacadeAppInsured;
import com.sq.partner.manager.service.FacadeAppBeneficiaryService;
import com.sq.partner.manager.service.FacadeAppInsuredService;
import com.sq.partner.manager.util.DateUtil;
import com.sq.partner.manager.util.LogUtil;

/**
 * 被保险人Service实现类
 * @author zhouxiuxiu
 *
 */
@Service
public class FacadeAppInsuredServiceImpl implements FacadeAppInsuredService {
    private static Logger logger =LogUtil.getLog(FacadeAppInsuredServiceImpl.class);
    
	@Resource
	FacadeAppInsuredDao facadeAppInsuredDao;
	
	@Resource
	FacadeAppBeneficiaryService facadeAppBeneficiaryService;
	
	@Resource
	FacadeAppFormDao facadeAppFormDao;
	
	
	/**
     * 保存被保人,并返回被保人ID
     * 
     * @param facadeAppInsured
     * @return
     * @throws Exception
     */
	@Override
	public FacadeAppInsured saveFacadeAppInsured(
	        FacadeAppInsured facadeAppInsured) throws Exception {
		//取得客户序列号
		String clientNo=facadeAppInsuredDao.queryNewClientNo();
		facadeAppInsured.setClientNo(clientNo);
		facadeAppInsured.setCreatTime(DateUtil.getNowTimestamp());
		facadeAppInsured.setUpdateTime(DateUtil.getNowTimestamp());
		//添加被保险人
		facadeAppInsuredDao.insertFacadeAppInsured(facadeAppInsured);
		return facadeAppInsured;
	}
	
	/**
     * 删除被保险人
     * @param appNo
     * @throws Exception
     */
    @Override
    public void deleteInsuredByAppNo(String appNo) throws Exception {
        facadeAppInsuredDao.deleteInsuredByAppNo(appNo);
    }
}
